package com.itlong.cloud.operate.resource;

import com.itlong.cloud.POJO.DTO.operate.OperateSceneGetPageDTO;
import com.itlong.cloud.POJO.DTO.operate.OperateSceneSaveDTO;
import com.itlong.cloud.POJO.PO.OperateScenePO;
import com.itlong.cloud.POJO.VO.operate.OperateSceneVO;
import com.itlong.cloud.operate.service.IOperateSceneService;
import com.itlong.cloud.project.operate.IOperateSceneServiceClient;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <desc>
 * 场景信息服务暴露接口实现类
 * </desc>
 *
 * @createDate 2021-03-25
 */
@RestController
public class OperateSceneServiceResource implements IOperateSceneServiceClient {

    @Autowired
    IOperateSceneService iOperateSceneService;

    /**
     * <desc>
     * 添加新场景
     * <desc/>
     *
     * @param saveDTO 新增场景信息
     * @return
     * @author zhouchun
     * @createDate 2021-03-25
     */
    @Override
    @RequestMapping(path = "/operate/scene/add", method = RequestMethod.POST)
    public Integer saveScene(@RequestBody OperateSceneSaveDTO saveDTO) throws Exception {
        Integer result = iOperateSceneService.saveScene(saveDTO);
        return result;
    }

    /**
     * <desc>
     * 修改新场景
     * <desc/>
     *
     * @param saveDTO 修改场景信息
     * @return
     * @author zhouchun
     * @createDate 2021-03-25
     */
    @Override
    @RequestMapping(path = "/operate/scene/update", method = RequestMethod.POST)
    public Integer updateScene(@RequestBody OperateSceneSaveDTO saveDTO) throws Exception {
        Integer result = iOperateSceneService.updateScene(saveDTO);
        return result;
    }

    @Override
    @RequestMapping(path = "/operate/scene/getCountByName", method = RequestMethod.POST)
    public Integer getCountByName(String name) {
        return iOperateSceneService.getCountByName(name);
    }

    @Override
    @RequestMapping(path = "/operate/scene/getExcludeCountByName", method = RequestMethod.POST)
    public Integer getExcludeCountByName(String name, String sceneKey) {
        return iOperateSceneService.getExcludeCountByName(name, sceneKey);
    }

    @Override
    @RequestMapping(path = "/operate/scene/getOneBySceneId", method = RequestMethod.POST)
    public OperateScenePO getOneBySceneId(String sceneId) {
        return iOperateSceneService.getOneBySceneId(sceneId);
    }

    /**
     * <desc>
     * 分页获取场景信息
     * <desc/>
     *
     * @param pageDTO 分页查询场景信息条件对象
     * @return
     * @author zhouchun
     * @createDate 2021-03-26
     */
    @Override
    @RequestMapping(path = "operate/scene/getPage", method = RequestMethod.POST)
    public Page<OperateSceneVO> getPage(@RequestBody OperateSceneGetPageDTO pageDTO) throws Exception {
        Page<OperateSceneVO> page = iOperateSceneService.getPage(pageDTO);
        return page;
    }

    @Override
    @RequestMapping(path = "operate/scene/userTypeIdCanDelete", method = RequestMethod.POST)
    public Integer userTypeIdCanDelete(String userTypeId) {
        return iOperateSceneService.userTypeIdCanDelete(userTypeId);
    }

    @Override
    @RequestMapping(path = "operate/scene/delete", method = RequestMethod.POST)
    public Integer delete(@RequestBody OperateScenePO m) {
        return iOperateSceneService.delete(m);
    }

}